package com.onejson.ojmall.controller;

import com.onejson.ojmall.entity.TestEntity;
import com.onejson.ojmall.entity.dto.TestDTO;
import com.onejson.ojmall.entity.vo.TestVO;
import com.onejson.ojmall.service.ITestService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 测试表
 *
 * @author 微信公众号 onejson
 * @date 2023-08-11
 */
@RestController
@RequestMapping(path = "/test", produces = "application/json;charset=UTF-8")
@Api(value = "/test", tags = "测试表", produces = "application/json;charset=UTF-8")
public class TestController{

    @Resource
    private ITestService testService;

    /**
     * 查询列表
     */
    @ApiOperation(value = "条件查询列表分页", notes = "条件查询列表分页")
    @GetMapping("/list")
    public List<TestEntity> list(TestEntity sysTest) {
        return testService.selectTestList(sysTest);
    }

    /**
     * 新增
     */
    @ApiOperation(value = "新增")
    @PostMapping
    public boolean add(@Validated @RequestBody TestDTO testDTO) {
        return testService.insertTest(testDTO);
    }

    /**
     * 修改
     */
    @ApiOperation(value = "更新")
    @PutMapping
    public boolean edit(@RequestBody TestDTO testDTO) {
        return testService.updateTest(testDTO);
    }

    /**
     * 详情
     */
    @ApiOperation(value = "详情")
    @GetMapping(value = "/{id}")
    public TestVO getInfo(@PathVariable("id") Integer id) {

        return testService.getTestById(id);
    }

    /**
     * 删除
     */
    @ApiOperation(value = "删除")
    @DeleteMapping("/{ids}")
    public boolean remove(@PathVariable Integer[] ids) {
        return testService.removeTestByIds(ids);
    }


}
